﻿using System;
using System.Collections.Generic;
using System.Text;


using System.Windows.Forms;

namespace Shine.Framework
{
    /// <summary>
    /// 类似ContextMenuStrip
    /// </summary>
    public class CommandBarClass : ICommandItem, ICommandBar, IWindowPosition
    {
        ContextMenuStrip m_ContextMenuStrip = null;

        #region User Define
        private string m_Action;
        public string Action
        {
            get
            {
                return m_Action;
            }
            set
            {
                m_Action = value;
            }
        }

        private bool m_BuiltIn;
        public bool BuiltIn
        {
            get
            {
                return m_BuiltIn;
            }
        }

        private string m_Caption;
        public string Caption
        {
            get
            {
                return m_Caption;
            }
            set
            {
                m_Caption = value;
            }
        }

        private string m_Category;
        public string Category
        {
            get
            {
                return m_Category;
            }
        }

        private ICommand m_Command;
        public ICommand Command
        {
            get
            {
                return m_Command;
            }
        }

        public int Count
        {
            get
            {
                return 0;
            }
        }


        private object m_FaceID;
        public object FaceID
        {
            get
            {
                return m_FaceID;
            }
            set
            {
                m_FaceID = value;
            }
        }
        private bool m_Group;

        public bool Group
        {
            get
            {
                return m_Group;
            }
            set
            {
                m_Group = value;
            }
        }
        private int m_Height;
        public int Height
        {
            get
            {
                return m_Height;
            }
            set
            {
                m_Height = value;
            }
        }

        private int m_HelpContextID;
        public int HelpContextID
        {
            get
            {
                return m_HelpContextID;
            }
            set
            {
                m_HelpContextID = value;
            }
        }

        private string m_HelpFile;
        public string HelpFile
        {
            get
            {
                return m_HelpFile;
            }
            set
            {
                m_HelpFile = value;
            }
        }

        //public UID ID
        //{
        //    get
        //    {
        //        return null;
        //    }
        //}

        private int m_Left;
        public int Left
        {
            get
            {
                return m_Left;
            }
            set
            {
                m_Left = value;
            }
        }

        public int Index
        {
            get
            {
                return 0;
            }
        }

        public string Message
        {
            get
            {
                return m_Command.Message;
            }
            set
            {
                // m_Command.Message = value;
            }
        }

        public string Name
        {
            get
            {
                return "";
            }
            set
            {
                ;
            }
        }

        private ICommandBar m_CommandBar;
        public ICommandBar Parent
        {
            get
            {
                return m_CommandBar;
            }
        }

        private esriWindowState m_State;
        public esriWindowState State
        {
            get
            {
                return m_State;
            }
            set
            {
                m_State = value;
            }
        }

        //private esriCommandStyles m_Style;
        //public esriCommandStyles Style
        //{
        //    get
        //    {
        //        return m_Style;
        //    }
        //    set
        //    {
        //        m_Style = value;
        //    }
        //}

        private string m_Tag;
        public string Tag
        {
            get
            {
                return m_Tag;
            }
            set
            {
                m_Tag = value;
            }
        }

        private string m_Tooltip;
        public string Tooltip
        {
            get
            {
                return m_Tooltip;
            }
            set
            {
                m_Tooltip = value;
            }
        }

        private int m_Top;
        public int Top
        {
            get
            {
                return m_Top;
            }
            set
            {
                m_Top = value;
            }
        }

        private esriCommandTypes m_Type;
        public esriCommandTypes Type
        {
            get
            {
                return m_Type;
            }
        }

        private int m_Width;
        public int Width
        {
            get
            {
                return m_Width;
            }
            set
            {
                m_Width = value;
            }
        }
        #endregion

        public CommandBarClass()
        {
            m_ContextMenuStrip = new ContextMenuStrip();
        }

        //public ICommandItem Add(UID cmdID, ref object Index)
        //{
        //    return null;
        //}

        public ICommandItem CreateMacroItem(string Name, ref object FaceID, string Action, ref object Index)
        {
            return null;
        }

        public ICommandBar CreateMenu(string Name, ref object Index)
        {
            ICommandItem m_CommandItem = new CommandBarClass();
            m_CommandItem.Name = Name;
            return m_CommandItem as ICommandBar;
        }

        public void Delete()
        {
            m_ContextMenuStrip = null;
        }

        public void Dock(esriDockFlags dockFlags, ICommandBar referenceBar)
        {

        }

        public void Execute()
        {

        }

        public ICommandItem Find(object identifier, bool noRecurse)
        {
            return null;
        }

        public ICommandItem this[int Index]
        {
            get
            {
                return m_ContextMenuStrip.Items[Index].Tag as ICommandItem;
            }
        }

        public bool IsVisible()
        {
            return true;
        }

        public void Move(int Left, int Top, int Width, int Height)
        {
            //m_ContextMenuStrip
        }

        public ICommandItem Popup(int X, int Y)
        {
            m_ContextMenuStrip.Show(X, Y);
            return null;
        }

        public void Refresh()
        {

        }

        public void Reset()
        {
            m_ContextMenuStrip.Items.Clear();
        }
    }
}


//public ICommandItem get_Item(int Index)
//{
//    return null;
//}